<?php
if(isset($_POST)){
  if($_POST[txtPassword]!=""){
	  
  $sql = "UPDATE tb_userinfo SET ui_password = '".$_POST[txtPassword]."' WHERE ui_id='".$_POST[txtUserId]."';";
  $rows = $db->query($sql);

  }

}
?>
<div align="left" class="listofusers">&nbsp;<a href="?ch=change_pass">Change Password</a></div>
<div class="form_area"><!-- Pagearea div start here -->
<form name="frmUserRegister" id="frmUserRegister" action="?ch=change_pass" method="post">
	<input type="hidden" name="txtUserId" id="txtUserId" value="<?php echo $_SESSION[userID];?>"/>  
   	<input type="hidden" name="txtClientId" id="txtClientId" value="<?php echo $_SESSION[clientID];?>"/>  
    
<ul class="form">
     <li>
        <label>New Password : </label> 
		<input type="password" id="txtPassword" name="txtPassword"/>
     </li>
	 <li>
        <label>Confirm New Password : </label>
        <input type="password" id="txtcPassword" name="txtcPassword"/>
     </li>
</ul>
  <p class="btn_area">
  		<input type="submit" name="cmdSubmitUpdateUserAdmin" id="cmdSubmitUpdateUserAdmin" value="Update" class="save_btn" />  
  </p>

</form>
</div>
 <script language="JavaScript" type="text/javascript">
 function DoCustomValidation()
{
  var frm = document.forms["frmUserRegister"];
  var pw1 = document.getElementById('txtPassword').value;
  var pw2 = document.getElementById('txtcPassword').value;
  
  if(pw1!="" || pw2!="")
  {
  		if(pw1.length<'8' || pw2.length<'8')
		{
		  sfm_show_error_msg('Min length for Password is 8',frm.pwd1);
		  return false;
		} 
		else 
		{
			if(pw1 != pw2)
			{  
			
				sfm_show_error_msg('The Password and verified password does not match!',frm.pwd1);
				return false;
			}
			else
			{
				return true;
			}
		}
   } 
   else 
   {
	    sfm_show_error_msg('Input Missing',frm.pwd1);
		return false;
   }
}
//You should create the validator only after the definition of the HTML form
  var frmvalidator  = new Validator("frmUserRegister");
  frmvalidator.setAddnlValidationFunction("DoCustomValidation");
  

  
</script>   
